package com.softserveinc.autorent.manager;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import com.softserveinc.autorent.model.User;

@Stateless
public class UserEJB extends AbstractEJB<User> {
	
	@PersistenceContext(unitName = "jpa")
	private EntityManager em;

	public UserEJB() {
		super(User.class);
	}
	
	@Override
	public EntityManager getEntityManager() {
		return em;
	}

	@Override
	public void setEntityManager(EntityManager em) {
		this.em = em;
	}

	@Override
	public List<User> findAll() {
        TypedQuery<User> query = em.createNamedQuery("findAllUsers", User.class);
        return query.getResultList();
	}

}
